# -*- coding: utf-8 -*-

"""
DateTime   : 2020/12/20 10:33
Author     : ZhangYafei
Description:
给出一个字符串，在程序中赋初值为一个句子，例如“To improve is to change;to be perfect is to change often.”,
需要：计算句子中各字符出现的频数（通过字典存储）
"""
sentence = 'To improve is to change;to be perfect is to change often.'
word_count = {}

for ch in sentence:
    word_count[ch] = word_count.get(ch, 0) + 1
    # if ch in word_count:
    #     word_count[ch] += 1
    # else:
    #     word_count[ch] = 1

print(word_count)